package com.pipayshop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pipayshop.entity.HotelShopInfo;
import com.pipayshop.entity.vo.IndexShopInfoVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 实体店的信息 Mapper 接口
 * </p>
 *
 * @author nws
 * @since 2023-07-25
 */
@Mapper
public interface HotelShopInfoMapper extends BaseMapper<HotelShopInfo> {


    /**
     * 首页获取商家信息列表
     */
    List<IndexShopInfoVO> getIndexShopInfoVO(
            @Param("categoryId") String categoryId
            ,@Param("page") Integer page
            ,@Param("limit") Integer limit
            ,@Param("score") Boolean score
            ,@Param("regionId") String regionId
            ,@Param("shopName") String shopName
            ,@Param("latitude") BigDecimal latitude
            ,@Param("longitude") BigDecimal longitude
    );
    // 根据模糊匹配regionId查询酒店数量
    long countHotelsByRegionPrefix(@Param("categoryId") String categoryId, @Param("regionIdPrefix") String regionIdPrefix);

    /**
     * 首页获取商家信息列表总条数
     */
    Integer getIndexShopInfoVOCount(@Param("categoryId") String categoryId, @Param("regionId") String regionId,@Param("shopName") String shopName);


    List<IndexShopInfoVO> getHotelInfoByCondition(@Param("shopName")String shopName,
                                                  @Param("limit") Integer limit,
                                                  @Param("page")Integer page,
                                                  @Param("checkInTime")Date checkInTime,
                                                  @Param("departureTime")Date departureTime,
                                                  @Param("adult")Integer adult,
                                                  @Param("children")Integer children,
                                                  @Param("regionId") String regionId);

    Integer getHotelInfoNum(@Param("shopName")String shopName,
                            @Param("checkInTime") Date checkInTime,
                            @Param("departureTime")Date departureTime,
                            @Param("adult")Integer adult,
                            @Param("children")Integer children,
                            @Param("regionId") String regionId);


    HotelShopInfo selectShopAllInfo(String shopId);


    @Update("UPDATE store_info SET upload_commodity_balance = upload_commodity_balance - 1 WHERE shop_id = #{shopId}")
    int updateCommodityBalance(String shopId);

    int updateDelFlag(List<String> deleteImageIds);

}
